package aufgabe_2_test.try02;

import java.io.Serializable;

/**
 * this class represent the information structure of a worker
 * @author J. Quenzel & R. Flaegel
 *
 */
public class WorkerObject implements Serializable{
	private static final long serialVersionUID = -8790719200862664366L;
	/**
	 * identifier of host, like name or ip adress
	 */
	private String identifier;
	/**
	 * port of destination host
	 */
	private int port;
	/**
	 * amount of worker for the calculation of factorisation
	 */
	private int AmountWorkers;
	
	public WorkerObject(String identifier, int port, int AmountWorkers) {
		this.identifier = identifier;
		this.port = port;
		this.AmountWorkers = AmountWorkers;
	}
	
	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}
	
	public void setPort(int port) {
		this.port = port;
	}
	
	public void setAmountWorkers(int amountWorkers) {
		AmountWorkers = amountWorkers;
	}
	
	public int getAmountWorkers() {
		return AmountWorkers;
	}
	
	public int getPort() {
		return port;
	}
	
	public String getIdentifier() {
		return identifier;
	}
	
	@Override
	public boolean equals(Object arg0) {
		if(!this.getClass().equals(arg0.getClass())){
			return false;
		}
		if(arg0 instanceof WorkerObject){
			WorkerObject wO = (WorkerObject) arg0;
			if(wO.identifier.equals(this.identifier) && wO.port == this.port){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}

}
